<ui:composition template="/layout/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	<ui:define name="title">Mise à jour Applications</ui:define>

	<ui:define name="content_header">Mise à jour données</ui:define>

	<ui:define name="content">
		<h:form id="applicationsForm">
		
				<p:panel id="formulaireApplication" style="width: 100%;hight: 100%;" >	
						<p:dataTable id="applicationsTable" var="applications"
						value="#{applicationsMB.applicationss}" rowKey="#{applications.applicationsId}"	selection="#{applicationsMB.selectedApplications}" selectionMode="single"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
							paginator="true" rows="10" style="margin-bottom:20px">
							<p:ajax event="rowSelect" listener="#{applicationsMB.onRowSelect}" update=":applicationsForm"/>
							<p:column>
								<f:facet name="header">
									<h:outputText value="Application ID" />
								</f:facet>
								<h:outputText value="#{applications.applicationsId}" />
							</p:column>

							<p:column>
								<f:facet name="header">
									<h:outputText value="Libelle" />
								</f:facet>
								<h:outputText value="#{applications.application}" />
							</p:column>

							<p:column>
								<f:facet name="header">
									<h:outputText value="Date de creation" />
								</f:facet>
								<h:outputText value="#{applications.createtimestamp}" />
							</p:column>

							<p:column>
								<f:facet name="header">
									<h:outputText value="Update Date" />
								</f:facet>
								<h:outputText value="#{applications.updatetimesstamp}" />
							</p:column>
						</p:dataTable>

					<hr/>
					<p:messages id="messages" autoUpdate="true"/>
					<h:panelGrid  id="formulaire" columns="2" columnClasses="label, value" align="left" width="100%">
					<h:outputText value="Application ID: " />
						<p:inputText value="#{applicationsMB.selectedApplications.applicationsId}" required="true" label="Application Id" disabled="true"/>

						<h:outputText value="Application: *" />
						<p:inputText value="#{applicationsMB.selectedApplications.application}" required="true" label="Application" size="50" />

					</h:panelGrid>
					
					<hr/>
					
	            <h:panelGrid columns="3" styleClass="alignLeft"> 	
	            	<p:commandButton value="Créer" icon="ui-icon-plus"   actionListener="#{applicationsMB.creer}" process="@this" update="applicationsForm" />   
			        <p:commandButton value="Update" icon="ui-icon-disk" actionListener="#{applicationsMB.enregistrer}" update="applicationsForm applicationsTable"/>
			        <p:commandButton value="Supprimer" icon="ui-icon-closethick" type="button"  onclick="confirmation.show()"/>
  
		        </h:panelGrid>	
		        
		        <p:confirmDialog id="confirmDialog" message="Etes-vous sûr de vouloir le supprimer ?"
					header="Suppression d'une application" severity="alert" widgetVar="confirmation">				
				<p:commandButton id="confirm" value="Oui" oncomplete="confirmation.hide()"
							actionListener="#{applicationsMB.supprimer}" update="applicationsForm">
												<f:ajax  update="formulaireApplication" />
				</p:commandButton>
				<p:commandButton id="decline" value="Non" onclick="confirmation.hide()" type="button" /> 							
			</p:confirmDialog>   
		        </p:panel>
		</h:form>
	</ui:define>
</ui:composition>